import sys
from PyQt5.QtWidgets import QLabel, QLineEdit, QPushButton, QWidget, QApplication, QDesktopWidget, QMessageBox, \
    QComboBox
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import pyqtSignal


class organize(QWidget):
    s1 = pyqtSignal()
    s2 = pyqtSignal()

    def rt(self):
        self.s1.emit()

    def org(self):
        self.s2.emit()

    def __init__(self):
        super().__init__()

    def initUI(self):
        self.l1 = QLabel('图书编号：', self)
        self.l2 = QLabel('选择状态：', self)
        self.e1 = QLineEdit(self)

        self.c1 = QComboBox(self)
        self.c1.addItems(['上架', '下架'])
        self.c1.currentText()

        self.l1.resize(self.l1.sizeHint())
        self.l1.move(40, 55)
        self.e1.resize(150, 20)
        self.e1.move(100, 50)
        self.l2.resize(self.l2.sizeHint())
        self.l2.move(40, 90)
        self.c1.resize(50, 20)
        self.c1.move(100, 85)

        self.b1 = QPushButton('确定', self)
        self.b2 = QPushButton('返回', self)
        self.b3 = QPushButton('退出', self)

        self.b1.resize(self.b1.sizeHint())
        self.b2.resize(self.b2.sizeHint())
        self.b3.resize(self.b3.sizeHint())

        self.b1.move(20, 130)
        self.b2.move(110, 130)
        self.b3.move(200, 130)

        self.b1.clicked.connect(self.org)
        self.b2.clicked.connect(self.rt)
        self.b3.clicked.connect(QApplication.instance().quit)

        self.resize(300, 180)
        self.setWindowTitle('管理图书')
        self.setWindowIcon(QIcon('icon.png'))
        self.show()

    def center(self):
        x = self.frameGeometry()
        y = QDesktopWidget().availableGeometry().center()
        x.moveCenter(y)
        self.move(x.topLeft())

    # def closeEvent(self, event):
    #     qt = QMessageBox(QMessageBox.Question, "系统提示", "是否退出")
    #     yap = qt.addButton("是", QMessageBox.YesRole)
    #     qt.addButton("否", QMessageBox.NoRole)
    #     qt.setWindowIcon(QIcon('Icon.png'))
    #     qt.exec_()
    #     if qt.clickedButton() == yap:
    #         event.accept()
    #     else:
    #         event.ignore()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    a = organize()
    a.initUI()
    sys.exit(app.exec_())
